#include "DateRange.h"

//DateRange::DateRange(QString dName, QDate sDate, QDate eDate)
//{
//    name=dName;
//    startDate=sDate;
//    endDate=eDate;
//}
DateRange::DateRange(const QString dName, const QDate sDate, const QDate eDate)
{
    name=dName;
    startDate=sDate;
    endDate=eDate;
}

DateRange::DateRange()
{
    name="";
    //    startDate=NULL;
    //    endDate=NULL;
}
QString DateRange::getName() const
{
    return this->name;
}

QDate DateRange::getStartDate() const
{
    return this->startDate;
}

QDate DateRange::getEndDate() const
{
    return this->endDate;
}

void DateRange::setName(QString newName)
{
    name=newName;
}

void DateRange::setStartDate(QDate newDate)
{
    startDate=newDate;
}

void DateRange::setEndDate(QDate newDate)
{
    endDate=newDate;
}

void DateRange::setDates(QDate newStartDate, QDate newEndDate)
{
    startDate=newStartDate;
    endDate=newEndDate;
}

bool DateRange::isInRangeOf(QDate date) const
{
    if (date >= startDate && date <=endDate)
        return true;
    else
        return false;
}

QDataStream &operator<<(QDataStream &out, const DateRange &data)
{
   out << data.getName() << data.getStartDate() << data.getEndDate();
   return out;
}

QDataStream &operator>>(QDataStream &in, DateRange &data)
{
    QString loadName;
    QDate loadStartTime;
    QDate loadEndTime;
    in >> loadName >> loadStartTime >>loadEndTime;
    data = DateRange(loadName, loadStartTime, loadEndTime);
    return in;
}
